from django import template
register = template.Library()

@register.filter(name="virt_host_status")
def virt_host_status(value, _type):
    if _type=="status":
        res = ""
        if value[0] == 5:
            res = "关机" 
        else:
            res = "运行中"
        return res + str(value)
    if _type == "img":
        if value[0] == 5:
            return 'filter:grayscale(100%);' 
        else:
            return ""
    if _type == "bool":
        if value[0] == 5:
            return False
        else:
            return True
    
